#ifndef _CERT_HELPER_H
#define _CERT_HELPER_H

#include "../LibUtil.h"

LIB_UTIL_NAMESPACE_BEGIN

class ICertHelper
{
public:
	static ICertHelper* CreateCertHelper();
	static void ReleaseCertHelper(ICertHelper* certHelper);

	//if keyData is null, use keyPath to load cert.
	//if keyPath is empty, use keyData to load cert.
	//if both empty, return false.
	virtual bool InitVerify(const string& keyPath = "", const tDataBuffer* keyData = NULL) = 0;
	virtual bool VerifyUpdate(const tDataBuffer& data) = 0;
	virtual bool Verfity(const tDataBuffer& signature, bool isBase64) = 0;

	//if keyData is null, use keyPath to load cert.
	//if keyPath is empty, use keyData to load cert.
	//if both empty, return false.
	virtual bool InitSign(const string& password, const string& keyPath = "", const tDataBuffer* keyData = NULL) = 0;
	virtual bool SignUpdate(const tDataBuffer& data) = 0;
	virtual bool Sign(tDataBuffer& signature, bool isBase64 = false) = 0;

	virtual void Release() = 0;

protected:
	virtual ~ICertHelper() {}
};

LIB_UTIL_NAMESPACE_END

#endif //_CERT_HELPER_H
